/*
 * Copyright (c) 2025 CAX Conversion Project
 */
package com.comac.ins.isfd.constant.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 调度任务状态枚举
 *
 * @author hxloongs
 * @date 2024-10-12
 */
@AllArgsConstructor
@Getter
public enum IsfdDatasourceTaskSchedulingConfigStatusEnum {
    NOT_RUNNING(0, "未执行"),
    RUNNING(1, "执行中"),
    SUSPEND(2, "中止");
    private final Integer value;
    private final String desc;

    public static String getDescByValue(Integer value) {
        IsfdDatasourceTaskSchedulingConfigStatusEnum isfdDatasourceTaskSchedulingConfigStatusEnum = forValue(value);
        if (isfdDatasourceTaskSchedulingConfigStatusEnum == null) {
            return null;
        }
        return isfdDatasourceTaskSchedulingConfigStatusEnum.getDesc();
    }

    public static IsfdDatasourceTaskSchedulingConfigStatusEnum forValue(Integer value) {
        if (value == null) {
            return null;
        }
        for (IsfdDatasourceTaskSchedulingConfigStatusEnum isfdDatasourceTaskSchedulingConfigStatusEnum : IsfdDatasourceTaskSchedulingConfigStatusEnum.values()) {
            if (isfdDatasourceTaskSchedulingConfigStatusEnum.getValue().equals(value)) {
                return isfdDatasourceTaskSchedulingConfigStatusEnum;
            }
        }
        return null;
    }

    public static IsfdDatasourceTaskSchedulingConfigStatusEnum forDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (IsfdDatasourceTaskSchedulingConfigStatusEnum isfdDatasourceTaskSchedulingConfigStatusEnum : IsfdDatasourceTaskSchedulingConfigStatusEnum.values()) {
            if (desc.equals(isfdDatasourceTaskSchedulingConfigStatusEnum.getDesc())) {
                return isfdDatasourceTaskSchedulingConfigStatusEnum;
            }
        }
        return null;
    }
}
